<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Example collection.xml and collection.xsl files</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="xsl.examples.html">« 范例</a></li>
      <li style="float: right;"><a href="xsl.examples-errors.html">Error handling with libxml error handling functions »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="xsl.examples.html">范例</a></li>
    <li>Example collection.xml and collection.xsl files</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="xsl.examples-collection" class="section">
  <h2 class="title">Example collection.xml and collection.xsl files</h2>
  <p class="para">
   Many examples in this reference require both an XML and an XSL file.
   We will use <var class="filename">collection.xml</var> and 
   <var class="filename">collection.xsl</var> that contains the following:
  </p>
  <p class="para">
   <div class="example" id="example-5497">
    <p><strong>示例 #1 collection.xml</strong></p>
    <div class="example-contents">
<div class="xmlcode"><pre class="xmlcode">&lt;collection&gt;
 &lt;cd&gt;
  &lt;title&gt;Fight for your mind&lt;/title&gt;
  &lt;artist&gt;Ben Harper&lt;/artist&gt;
  &lt;year&gt;1995&lt;/year&gt;
 &lt;/cd&gt;
 &lt;cd&gt;
  &lt;title&gt;Electric Ladyland&lt;/title&gt;
  &lt;artist&gt;Jimi Hendrix&lt;/artist&gt;
  &lt;year&gt;1997&lt;/year&gt;
 &lt;/cd&gt;
&lt;/collection&gt;</pre>
</div>
    </div>

   </div>
   <div class="example" id="example-5498">
    <p><strong>示例 #2 collection.xsl</strong></p>
    <div class="example-contents">
<div class="xmlcode"><pre class="xmlcode">&lt;xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot;&gt;
 &lt;xsl:param name=&quot;owner&quot; select=&quot;&#039;Nicolas Eliaszewicz&#039;&quot;/&gt;
 &lt;xsl:output method=&quot;html&quot; encoding=&quot;iso-8859-1&quot; indent=&quot;no&quot;/&gt;
 &lt;xsl:template match=&quot;collection&quot;&gt;
  Hey! Welcome to &lt;xsl:value-of select=&quot;$owner&quot;/&gt;&#039;s sweet CD collection! 
  &lt;xsl:apply-templates/&gt;
 &lt;/xsl:template&gt;
 &lt;xsl:template match=&quot;cd&quot;&gt;
  &lt;h1&gt;&lt;xsl:value-of select=&quot;title&quot;/&gt;&lt;/h1&gt;
  &lt;h2&gt;by &lt;xsl:value-of select=&quot;artist&quot;/&gt; - &lt;xsl:value-of select=&quot;year&quot;/&gt;&lt;/h2&gt;
  &lt;hr /&gt;
 &lt;/xsl:template&gt;
&lt;/xsl:stylesheet&gt;</pre>
</div>
    </div>

   </div>
  </p>
 </div></div></div></body></html>